package leetcode;

/**
 * Created by baoyunfeng on 2018/1/31.
 * https://leetcode.com/problems/search-insert-position/description/
 */
public class Search_Insert_Position {

    public static void main(String args[]){
        int nums[] = {1,2,3,4};
        for(int i = 0 ;i <nums.length;i++){
            System.out.print(nums[i]+" ");
        }
        System.out.println(searchInsert(nums,3));
    }

    public static int searchInsert(int[] nums, int target) {

        for(int i = 0 ;i < nums.length ;i++){
            if(nums[i]>=target){
                return i;
            }
        }
        return nums.length;
    }
}
